package net.wanho.hospital.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.wanho.hospital.po.Arrange;
import net.wanho.hospital.service.ArrangeService;
import net.wanho.hospital.vo.AjaxResult;
import org.springframework.web.bind.annotation.*;
import lombok.RequiredArgsConstructor;
import java.io.Serializable;
import java.util.List;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 汤小洋
 * @since 2023-12-27
 */
@Api(tags = "接口")
@RestController
@RequestMapping("/arrange")
@RequiredArgsConstructor
public class ArrangeController {

    private final ArrangeService arrangeService;

    @ApiOperation("分页查询")
    @GetMapping("/findByTime")
    public AjaxResult findByTime(String arTime, String dSection){
        List<Arrange> list = arrangeService.findByTime(arTime,dSection);
        return AjaxResult.success(list);
    }

    @ApiOperation("按主键查询")
    @GetMapping("/{arId}")
    public AjaxResult getById(@ApiParam("学号") @PathVariable Serializable arId){
        return AjaxResult.success(arrangeService.getById(arId));
    }

    @ApiOperation("新增")
    @GetMapping("/addArrange")
    public AjaxResult add(Arrange arrange){
        arrangeService.save(arrange);
        return AjaxResult.success();
    }

    @ApiOperation("修改")
    @PutMapping
    public AjaxResult edit(@RequestBody Arrange arrange){
        arrangeService.updateById(arrange);
        return AjaxResult.success();
    }

    @ApiOperation("按主键删除")
    @DeleteMapping("/{arId}")
    public AjaxResult removeById(@ApiParam("学号") @PathVariable Serializable arId){
        arrangeService.removeById(arId);
        return AjaxResult.success();
    }
}
